<template>
  <view class="container">
    <!-- 表单内容 -->
    <u-form class="form-content">
      <!-- 行政区划选择 -->
      <u-form-item label="省" class="form-item" label-width="120">
        <view class="arrow-icon-groud">
        <u-input
          v-model="formData.region"
          @click="changeOpenRegionPicker"
          class="custom-input"
        />
          <u-icon
                  name="arrow-right"
                  size="20"
                  class="arrow-icon"
          />
        </view>
        <area-picker
          ref="regionPicker"
          :title="regiontitle"
          titleColor="#808080"
          titleFontSize="14px"
          cancelType="icon"
          cancelColor="#999999"
          cancleFontSize="28rpx"
          confirmColor="#2877FF"
          confirmFontSize="14px"
          confirmFontWeight="500"
          itemFontSize="14px"
          @onClose="closeRegionPicker"
          @onConfirm="confirmRegionPicker"
          :pickerList="listRegion"
        />
      </u-form-item>

      <!-- 车牌颜色选择 -->
      <u-form-item label="地市" class="form-item" label-width="120">
        <view class="arrow-icon-groud">
          <u-input
            class="custom-input"
            v-model="formData.plateColor"
            @click="changeOpenCarColor"
          />
          <!-- 向下/向上箭头图标 -->
          <u-icon
            name="arrow-right"
            size="20"
            class="arrow-icon"
          />
        </view>

        <area-picker
          ref="carPicker"
          :title="title"
          titleColor="#808080"
          titleFontSize="14px"
          cancelType="icon"
          cancelColor="#999999"
          cancleFontSize="28rpx"
          confirmColor="#2877FF"
          confirmFontSize="14px"
          confirmFontWeight="500"
          itemFontSize="14px"
          @onClose="closeCarPicker"
          @onConfirm="confirmCarPicker"
          :pickerList="list"
        />
      </u-form-item>

      <!-- 车牌颜色选择 -->
      <u-form-item label="县" class="form-item" label-width="120">
        <view class="arrow-icon-groud">
          <u-input
                  class="custom-input"
                  v-model="formData.plateColor"
                  @click="changeOpenCarColor"
          />
          <!-- 向下/向上箭头图标 -->
          <u-icon
                  name="arrow-right"
                  size="20"
                  class="arrow-icon"
          />
        </view>

        <area-picker
                ref="carPicker"
                :title="title"
                titleColor="#808080"
                titleFontSize="14px"
                cancelType="icon"
                cancelColor="#999999"
                cancleFontSize="28rpx"
                confirmColor="#2877FF"
                confirmFontSize="14px"
                confirmFontWeight="500"
                itemFontSize="14px"
                @onClose="closeCarPicker"
                @onConfirm="confirmCarPicker"
                :pickerList="list"
        />
      </u-form-item>

      <!-- 车牌颜色选择 -->
      <u-form-item label="视频平台" class="form-item" label-width="120">
        <view class="arrow-icon-groud">
          <u-input
                  class="custom-input"
                  v-model="formData.plateColor"
                  @click="changeOpenCarColor"
          />
          <!-- 向下/向上箭头图标 -->
          <u-icon
                  name="arrow-right"
                  size="20"
                  class="arrow-icon"
          />
        </view>

        <area-picker
                ref="carPicker"
                :title="title"
                titleColor="#808080"
                titleFontSize="14px"
                cancelType="icon"
                cancelColor="#999999"
                cancleFontSize="28rpx"
                confirmColor="#2877FF"
                confirmFontSize="14px"
                confirmFontWeight="500"
                itemFontSize="14px"
                @onClose="closeCarPicker"
                @onConfirm="confirmCarPicker"
                :pickerList="list"
        />
      </u-form-item>

      <!-- 车牌号码输入 -->
      <u-form-item label="经营业户" class="form-item" label-width="120">
        <u-input
                v-model="formData.plateNumber"
                placeholder="请输入经营业户名称"
                class="custom-input"
        />
      </u-form-item>

      <!-- 道路运输证号输入 -->
      <u-form-item label="运营车辆" class="form-item" label-width="120">
        <u-input
          v-model="formData.transportNumber"
          placeholder="请输入运营车辆车牌号"
          class="custom-input"
        />
      </u-form-item>

      <!-- 车牌颜色选择 -->
      <u-form-item label="音视频通道" class="form-item" label-width="120">
        <view class="arrow-icon-groud">
          <u-input
                  class="custom-input"
                  v-model="formData.plateColor"
                  @click="changeOpenCarColor"
          />
          <!-- 向下/向上箭头图标 -->
          <u-icon
                  name="arrow-right"
                  size="20"
                  class="arrow-icon"
          />
        </view>

        <area-picker
                ref="carPicker"
                :title="title"
                titleColor="#808080"
                titleFontSize="14px"
                cancelType="icon"
                cancelColor="#999999"
                cancleFontSize="28rpx"
                confirmColor="#2877FF"
                confirmFontSize="14px"
                confirmFontWeight="500"
                itemFontSize="14px"
                @onClose="closeCarPicker"
                @onConfirm="confirmCarPicker"
                :pickerList="list"
        />
      </u-form-item>

      <!-- 车牌颜色选择 -->
      <u-form-item label="音视频资源" class="form-item" label-width="120">
        <view class="arrow-icon-groud">
          <u-input
                  class="custom-input"
                  v-model="formData.plateColor"
                  @click="changeOpenCarColor"
          />
          <!-- 向下/向上箭头图标 -->
          <u-icon
                  name="arrow-right"
                  size="20"
                  class="arrow-icon"
          />
        </view>

        <area-picker
                ref="carPicker"
                :title="title"
                titleColor="#808080"
                titleFontSize="14px"
                cancelType="icon"
                cancelColor="#999999"
                cancleFontSize="28rpx"
                confirmColor="#2877FF"
                confirmFontSize="14px"
                confirmFontWeight="500"
                itemFontSize="14px"
                @onClose="closeCarPicker"
                @onConfirm="confirmCarPicker"
                :pickerList="list"
        />
      </u-form-item>

    </u-form>

    <!-- 查询按钮 -->
    <view class="btn-container">
      <u-button @click="submitForm">立即查询</u-button>
    </view>

    <view class="list-item">
      <u-button>车辆列表</u-button>
      <u-button>视频列表</u-button>
      <u-button>播放视频</u-button>
    </view>
  </view>
</template>

<script>
import areaPicker from "@/components/area-picker/area-picker.vue";
import { changePlatecolor, vehiChangeProname } from "@/common/util_complete.js";
export default {
  components: {
    areaPicker,
  },
  data() {
    return {
      title: "选择车牌颜色",
      regiontitle: "选择管辖机构",
      formData: {
        region: "", // 行政区划
        plateNumber: "", // 车牌号码
        plateColor: "", // 车牌颜色
        transportNumber: "", // 道路运输证号
      },
      listRegion: [], // 行政区划选择
      list: [], // 车牌颜色选择
    };
  },
  onLoad(options) {
    // this.populateList(); // 在加载时填充数据
    this.list = changePlatecolor(this.list);
    this.listRegion = vehiChangeProname(this.listRegion);
  },

  methods: {

    // 打开车牌颜色选择器
    changeOpenCarColor() {
      this.$refs.carPicker._open();
    },
    // 打开行政区划选择器
    changeOpenRegionPicker() {
      this.$refs.regionPicker._open();
    },

    // 关闭选择器
    closeCarPicker() {
      this.$refs.carPicker._close();
    },
    closeRegionPicker() {
      this.$refs.regionPicker._close();
    },

    confirmCarPicker(checkedValue) {
      this.formData.plateColor = checkedValue;
    },

    confirmRegionPicker(checkedValue) {
      this.formData.region = checkedValue;
    },

    submitForm() {
      uni.navigateTo({
        url: "/pages/hub_ygzw/vehicle/vehicleInfo",
      });
      return;
      if (!this.formData.plateNumber || !this.formData.transportNumber) {
        uni.showToast({
          title: "请填写完整信息",
          icon: "none",
        });
        return;
      }
      // 提交表单逻辑
      console.log("查询提交", this.formData);
    },
  },
};
</script>

<style scoped lang="scss">
.container {
  padding: 10px;
  background-color: #f3f6fa;
  height: 100vh;
  box-sizing: border-box;
}

.form-content {
  background-color: #ffffff;
  padding: 0;
  /* 去掉 padding */
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-item {
  padding: 0 10px;
  border-bottom: 1px solid #f1f1f1;
  /* 设置下边框 */
}

.custom-input {
  border: none;
  /* 去掉输入框的边框 */
  background-color: transparent;
  /* 使背景透明 */
}

.btn-container {
  margin-top: 10px;
  text-align: center;
  position: absolute;
  right: 0;
  padding: 0 20px;
  width: 100%;
  box-sizing: border-box;
  ::v-deep .u-button--info[data-v-461e713c] {
    width: 100%;
    background-color: #2877ff;
    color: #ffffff;
  }
}

.arrow-icon-groud {
  position: relative;
  flex: 1;

  .arrow-icon {
    position: absolute !important;
    right: 20px;
    top: 10px;
  }
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 60px;
  height: 32px;
  background-color: #ffffff;
  padding: 0;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
</style>
